<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/


$api = app('Dingo\Api\Routing\Router');
$api->version('v1', [
    'namespace' => 'App\Http\Controllers\Api\V1',
    'middleware' => 'serializer:array'
    // composer require liyu/dingo-serializer-switch
    // 'middleware' => ['serializer:array', 'bindings']  没有路由应该报  例如：id 不存在，就应该报错 404，而不是 500
    // app/Providers/AppServiceProvider.php => register 下面要写代码
], function($api) {

    $api->post('users/forget', 'UserController@forget')->name('api.user.forget'); // 忘记密码
    $api->post('users', 'UserController@store')->name('api.user.store'); // 注册C
    $api->post('auths', 'AuthController@store')->name('api.auth.store'); // 登录C，前端

    // 图片验证码
    $api->post('captchas', 'CaptchaController@store')->name('api.captchas.store');// C
    $api->post('sendSms', 'SendSmsController@store')->name('api.sendSms.store');
    // 1 分钟 5 次
    $api->group(['middleware' => 'api.throttle', 'limit' => config('app.limitGetRequest'), 'expires' => config('app.expiresGetRequest')], function($api) { // phone ref_code 防止攻击 预设一分钟访问几次
        $api->get('phone', 'GetRequest\PhoneController@index')->name('api.phone.index');
        $api->get('ref_code', 'GetRequest\RefCodeController@index')->name('api.ref_code.index');

    });

    $api->group(['middleware' => 'api.auth'], function($api) {

        $api->get('trade_queues', 'TradeQueueController@index')->name('api.trade_queue.index');         // 获取 加友记录 | 提现记录
        $api->get('trade_queues/{type}/match_orders', 'SupplementSheetController@index');               // 匹配记录
        $api->get('round_static_profits', 'RoundStaticProfitController@index');                         // 预计收益率


        $api->post('trade_queues/{type}/match_orders', 'SupplementSheetController@store');               // 匹配记录

        $api->post('trade_queues', 'TradeQueueController@store')->name('api.trade_queue.store');        // 加友记录 | 提现记录

        $api->get('user', 'UserController@me')->name('api.user.show');        // 当前登录用户信息
        $api->post('evpi', 'UserController@evpi')->name('api.user.evpi');        // 完善用户信息
        $api->put('auths/current', 'AuthController@update');     // 刷新token
        $api->delete('auths/current', 'AuthController@destroy'); // 删除token

        $api->post('manual/match_orders', 'MatchOrderController@store'); // 手动匹配订单

        //$api->delete('match_orders', 'SupplementSheetController@destroy'); // 取消匹配的订单
        $api->post('complains', 'ComplainController@store')->name('api.complain.store'); // 提交申诉


        $api->post('assets', 'AssetController@store')->name('api.asset.store');        // 静态收益
        $api->get('notices', 'NoticeController@index')->name('api.notice.index');        // 获取公告列表
        $api->post('notices', 'NoticeController@store')->name('api.notice.store');        // 获取公告列表


    });
});